<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>材质</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp" %>  
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    <div class="form-group form-group-xs">
                        <label for="searchMaterialCode">材质编码：</label>
                        <input class="form-control" type="text" id="searchMaterialCode" placeholder="材质编码" maxlength="10" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="searchMaterialName">材质名称：</label>
                        <input class="form-control" type="text" id="searchMaterialName" placeholder="材质名称" maxlength="50" />
                    </div>
                    <button type="button" class="btn btn-success btn-sm" onclick="search();">查询</button>
                </div>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
            <button type="button" id="confirm"  onclick="confirm();" class="btn btn-default btn-sm">确认</button>
        </div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
            
            function search(page) {
                var Code = $("#searchMaterialCode").val();
                var Name = $("#searchMaterialName").val();
                $("#gridlist").jqGrid('setGridParam',{  
                    datatype:'json',
                    postData:{"materialCode":Code, "materialName":Name},
                    page : (page || 1)
                }).trigger("reloadGrid"); //重新载入  
            }
        
            $(function () {
                
                $("#gridlist").jqGrid({
                    url: "${ctx}/prodDrug/getDrugSelectMaterial.html",
                    mtype: "POST",
                    datatype: "json",
                    autowidth: true,
                    height: 270,
                    colNames: [ 'id','材质编码', '材质名称'],
                    colModel: [
                        { name: 'materialId', width: 10,hidden : true, align:"center", sortable: false},
                        { name: 'materialCode', width: 10, align:"center", sortable: false},
                        { name: 'materialName', width: 10, align:"center", sortable: false }
                    ],
                    rowNum: 20,
                    rowList: [10, 20, 50,100],
                    rownumbers: true,
                    pager: "#gridpage",
                    viewrecords: true,
                    caption: "材质",
                    jsonReader: {
                        id: "materialId"
                    }

                });
                
                $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
                $(window).trigger("resize");
              
            });
            
          //确认
            function confirm() {
                var rowId = $("#gridlist").jqGrid("getGridParam", "selrow") || [];
                 if(rowId.length <=0){
                    $.HN.message.alert("请选择要操作的行！", "消息", "warn");
                    return;
                 }
                 var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
                 var dialog = top.dialog.get(window);
                 var params = {
                    "materialId" : rowdata.materialId,
                    "materialName" : rowdata.materialName
                 };
                 dialog.close(params);   // 关闭（隐藏）对话框
                 dialog.remove();        // 主动销毁对话框
            }
           
    </script>
</body>
</html>
